# Maintainer: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>

pkgname=znc
pkgver=1.8.2
pkgrel=2
pkgdesc='An IRC bouncer with modules & scripts support'
url='https://znc.in/'
license=('Apache 2.0')
arch=('i686' 'x86_64')
replaces=('znc-git')
conflicts=('znc-git')
depends=('openssl' 'icu')
makedepends=('cmake'
             'cyrus-sasl'
             'gettext-devel'
             'git'
             'icu-devel'
             'libsasl-devel'
             'perl'
             'python'
             'swig'
             #'tcl'
             )
optdepends=('tcl: modtcl module'
            'python: modpython module'
            'perl: modperl module'
            'cyrus-sasl: cyrusauth module')
source=(znc-${pkgver}::git+https://github.com/znc/znc.git#tag=znc-${pkgver}
        #https://github.com/znc/znc/archive/znc-${pkgver}.tar.gz
        'znc-msysize.patch')
sha256sums=('SKIP'
            '9a748a69df8dbd143dd3a307570fb28205ee5344861690b5a1b37adb56d0652c')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -p1 -i ${srcdir}/znc-msysize.patch
  git submodule update --init --recursive
  #./autogen.sh
}

build() {
  [[ -d "${srcdir}/build-${CARCH}" ]] && rm -rf "${srcdir}/build-${CARCH}"
  mkdir -p "${srcdir}/build-${CARCH}" && cd "${srcdir}/build-${CARCH}"

  cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_BUILD_TYPE=Release \
    -DWANT_CYRUS=ON \
    -DWANT_PERL=ON \
    -DWANT_PYTHON=ON \
    -DWANT_I18N=OFF \
    ../${pkgname}-${pkgver}
  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 ${srcdir}/${pkgname}-${pkgver}/LICENSE ${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE
}
